<template>
	<view class="container">
		<view class="ch">
			<text>{{obj.note}}</text>
		</view>
		<view class="en">
			<text>{{obj.content}}</text>
		</view>

		<view class="img">
			<image :src="obj.img" mode="widthFix"></image>
			<view class="float_view">
				<image src="@/static/z.png"  @click="bjMusicClick()" v-if="musicShow"></image>
				<image src="@/static/k.png"  @click="bjMusicClick()" v-else></image>
			</view>
		</view>
		


	</view>
</template>

<script>
	import {
		get_englishs
	} from '@/api/index.js'
	const innerAudioContext = uni.createInnerAudioContext();
	export default {
		data() {
			return {
				musicShow:true,
				obj: ''
			}
		},
		mounted() {
			this.get_wenzi()
			innerAudioContext.autoplay = true; //自动播放
			innerAudioContext.loop = true; //循环播放
			//音乐播放
			innerAudioContext.play()
			//音乐地址
			innerAudioContext.src = this.obj.tts;
		},

		methods: {
			get_wenzi() {
				get_englishs().then(res => {
					if (res.data.code == 200) {
						this.obj = res.data.result
					}
				})
			},
			bjMusicClick() {
				if (this.musicShow == true) {
					// 暂停音乐
					// console.log('暂停')
					innerAudioContext.pause();
					this.musicShow = false
				} else if (this.musicShow == false) {
					// 播放音乐
					// console.log('播放')
					innerAudioContext.play()
					this.musicShow = true
				}

			},
		}
	}
</script>

<style scoped>
	.container {
		padding: 25rpx;
		box-sizing: border-box;
	}

	.ch {
		font-size: 40rpx;
		font-weight: 600;
		font-family: '微软雅黑';
		color: #333;
		line-height: 60rpx;
		border-bottom: 1rpx solid #ccc;
		padding-bottom: 25rpx;
	}

	.en {
		font-size: 40rpx;
		font-family: "Times New Roman", Times, serif;
		color: #333;
		line-height: 60rpx;
		padding-bottom: 25rpx;
	}

	.img {
		width: 100%;
		position: relative;
		
	}

	.img image {
		width: 100%;
	}
	.float_view {
		width: 60rpx;
		height: 60rpx;
		position:absolute;
		right: 20rpx;
		top:20rpx;
		z-index: 9;
		background: url(@/static/muc.png) no-repeat;
		background-size: 100% 100%;
		animation: configure-xclockwise 3s ease-in-out 0s infinite alternate;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.float_view image {
		width:40rpx;
		height:40rpx;
	}

	@keyframes configure-xclockwise {
		0% {
			transform: rotate(45deg);
		}
		100% {
			transform: rotate(-360deg);
		}
	}
</style>